<?php
// - UNDER-Development (idea, not finished, for multiple sort parameters instead of just 1... needs work)


class CF_SortOrder {

	var $order_set;
	var $req_order_param = 'order';
	var $req_dir_param = 'dir';
	
	function GetRequestSortOrder($method = 'REQUEST'){
		// for now, work only with REQUEST
		$order = $_REQUEST[$this->req_order_param];
		if(is_array($req_order)){
			foreach($req_order AS $order){
				if($order != ''){
					$ar_order['field'] = $order;
					// get the direction parameter - defaults to 'ASC' unless 'DESC' is passed in
					$ar_order['dir'] = $_REQUEST[$this->req_order_param][$key][$this->$req_dir_param];
					($ar_order['dir'] != 'DESC')?$ar_order['dir'] = 'ASC',$ar_order['dir'] = 'DESC';
					$this->order_set[] = $ar_order;
				}
			}
		
		}else{
			
		}
	
	}
	
	function ClearSort(){

	}

	function SortToSession(){
		$_SESSION[sort] = $this->order_set;
	}
	
	function SortFromSession(){
		return $_SESSION[sort];
	}
	
	function AddSort($fieldname,$direction = 'ASC'){
		if($direction != 'DESC'){
			$direction = 'ASC';
		}
		$order_set[] = array( 'field' => $fieldname, 'dir' => '$direction'); 
	}

	function SingleSort(){
	
	}


}

?>